import { DataTpEnum } from '@/modules/bmppd/enums/DataTpEnum';
import { BizStCdEnum } from '@/modules/bmppd/enums/BizStCdEnum';
import { AftrTpCdEnum } from '@/modules/bmppd/enums/AftrTpCdEnum';

export class ProdAttr {
  attrId: string | undefined = undefined;
  attrCd = '';
  attrNm = '';
  attrGrpNm = '';
  dataTpCd: DataTpEnum = DataTpEnum.TEXT;
  val: string | undefined = undefined;
  unit = '';
  unitNm = '';
  skuFlg = 0;
  cstmFlg = 0;
  ordrNum = 0;
  rmrk = '';
  optList: { optLab: string; optVal: string }[] = [];
}

export class ProdSku {
  key = '';
  skuCd = '';
  skuNo = '';
  skuNm = '';
  skuAttrList = '';
  attrGroupNm = ''; //用于显示规格组合后的名称，如：颜色:黑色 尺码:L;
  barCd = '';
  picUrl = '';
  wght = 0;
  len = 0;
  width = 0;
  higt = 0;
  stock = 0;
  prc = 0;
  vipPrc = 0;
  mktPrc = 0;
  costPrc = 0;
  dfltFlg = 0;
  rmrk = '';

  constructor() {
    this.key = String(Date.now()) + Math.floor(Math.random() * 10000);
  }
}

export class FormData {
  submtFlg = 0; //0 为保存，1为提交审批
  bizStCd: BizStCdEnum | null = null;
  prodId = '';
  prodNo = '';
  prodNm = '';
  prodSynps = '';
  prodDetails = '';
  prodTpId: string | null = null;
  prodCgyId: string | null = null;
  cvrUrl = '';
  picUrlList = '';
  vidUrl = '';
  brdId: string | null = null;
  brdNm: string | null = null;
  subTitl = '';
  unit = '';
  unitNm = '';
  skuFlg = 0;
  soldQty = 0;
  stBuyQty = 0;
  stock = 0;
  prc = 0;
  vipPrc = 0;
  costPrc = 0;
  mktPrc = 0;
  score = 0;
  recoFlg = 0;
  frtTempId = '';
  rmrk = '';
  attrList: ProdAttr[] = [];
  skuList: ProdSku[] = [];
  aftrTpCd: AftrTpCdEnum = AftrTpCdEnum.NOT;
  rtnTpCdAry = '';
  aftrTmLmt = 0;
  prodKindCd = 1;

  constructor() {
    this.skuList = [Object.assign(new ProdSku(), { dfltFlg: 1 })];
  }
}
